package com.woniuxy.tmsdriverassignment.service.imp;

import com.woniuxy.tmsdriverassignment.domain.wDriver;
import com.woniuxy.tmsdriverassignment.mapper.DriverMapper;
import com.woniuxy.tmsdriverassignment.service.DriverService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO:
 * <P> Date: 2022/4/20:15:54
 * <P> Description:
 */
@Service
public class DriverServiceImpl implements DriverService {

    @Resource
    private DriverMapper driverMapper;

    @Override
    public int addDriver(int waybill_id,int driver_id) {
        int i = driverMapper.addDriver(waybill_id,driver_id);
        if (i>0){
            //修改运单状态
            driverMapper.updateWaybill(waybill_id);
        }
        return i;
    }

    @Override
    public List<wDriver> getall(wDriver wDriver) {
       List<wDriver> list= driverMapper.getall(wDriver);
        return list;
    }

    @Override
    public int updateOrder(int id, int waybill_id, int driver_id) {
        int i = driverMapper.updateOrder(id,waybill_id,driver_id);
        return i;
    }

//    @Override
//    public int updateOrder() {
//
//        return i;
//    }

    @Override
    public int delete(int id) {
        wDriver wDriver = driverMapper.getOne(id);
        int i = driverMapper.delete(id);
        if (i>0){
            //修改运单状态
            driverMapper.updateWaybill1(wDriver.getWaybill_id());
        }
        return i;
    }

    @Override
    public wDriver getOne(int id) {
        wDriver one = driverMapper.getOne(id);
        return one;
    }
}
